import json
from typing import Dict

from fitframework.api.decorators import fitable

from .components.info_extract import field_info_extract_impl, synonym_replace_impl
from .components.dsl_generate import get_complete_query_impl, get_dsl_example_impl
from .components.question_classify import question_classify_impl
from .components.sql_constructor import dsl2sql_impl


@fitable("generic_synonym_replace", "fitable_synonym_replace")
def synonym_replace(query: str):
    new_query = synonym_replace_impl(query)
    return new_query


@fitable("generic_info_extract", "fitable_info_extract")
def info_extract(query: str):
    field_info = field_info_extract_impl(query)
    return field_info


@fitable("generic_question_classify", "fitable_question_classify")
def question_classify(query: str, key_info: str):
    query_type = question_classify_impl(query, key_info)
    return query_type


@fitable("generic_get_complete_query", "fitable_get_complete_query")
def get_complete_query(query: str, key_info: str, field_info: str):
    complete_query = get_complete_query_impl(query, key_info, field_info)
    return complete_query


@fitable("generic_get_dsl_example", "fitable_get_dsl_example")
def get_dsl_example(query_type: str):
    dsl_example = get_dsl_example_impl(query_type)
    return dsl_example


@fitable("generic_dsl2sql", "fitable_dsl2sql")
def get_dsl_example(dsl: str, query_type: str):
    sql = dsl2sql_impl(dsl, query_type)
    return sql
